package com.dit.thucydidestest.steps;


import com.dit.thucydidestest.pages.DictionaryPage;

import net.thucydides.core.annotations.Screenshots;
import net.thucydides.core.annotations.Step;
import net.thucydides.core.pages.Pages;
import net.thucydides.core.steps.ScenarioSteps;
import static ch.lambdaj.Lambda.join;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.hasItem;
import net.thucydides.core.annotations.Step;
import net.thucydides.core.pages.Pages;
import net.thucydides.core.steps.ScenarioSteps;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

public class EndUserSteps extends ScenarioSteps {

    DictionaryPage dictionaryPage;
    HomePage homePage;
    @Step
    @Screenshots(afterEachStep=true)
    public void enters(String keyword) {
        dictionaryPage.enter_keywords(keyword);
    }

    @Step
    @Screenshots(afterEachStep=true)
    public void starts_search() {
        dictionaryPage.lookup_terms();
    }

    @Step
    @Screenshots(beforeAndAfterEachStep=true)
    public void should_see_definition(String definition) {
        assertThat(dictionaryPage.getDefinitions(), hasItem(containsString(definition)));
    }

    @Step
    @Screenshots(forEachAction=true)
    public void is_the_home_page() {
        dictionaryPage.open();
        
    }

    @Step
    @Screenshots(forEachAction=true)
    public void looks_for(String term) {
        enters(term);
        starts_search();
        System.out.println("Test");
    }
    @Step
    @Screenshots(forEachAction=true)
	public void searches_for(String keyword) {
		homePage.enter_keywords(keyword);
		
	}
    @Screenshots(forEachAction=true)
	@Step
	public void should_see_article_with_title(String title) {
		assertThat(homePage.getTitle(),is(title));
		
	}
}